package edu.egypt.listalertdialogsample;


import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class ListAlertDialogSampleActivity extends Activity {
	private Button button;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        intializeUI();
    }

	private void intializeUI() {
		button = (Button)findViewById(R.id.button1);
		button.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				AlertDialog.Builder builder = new AlertDialog.Builder(ListAlertDialogSampleActivity.this);
				builder.setTitle("Choose one item");
				final CharSequence[] items ={"1","2","3","4"};
				builder.setItems(items,new DialogInterface.OnClickListener() {
					
					@Override
					public void onClick(DialogInterface dialog, int which) {
						Toast.makeText(ListAlertDialogSampleActivity.this, items[which], Toast.LENGTH_SHORT).show();
					}
				});
				builder.show();
				
				
			}
		});
	}
}